#!/bin/sh

# XML Master
# 
# 1, Config parametr batch update.
#
# @Author: liaobaikai(食草皮蛋)
# @Date:   2024-09-23 ~ 2024-09-26
# @Version: 1.0.1
# ---------------------------------------------
# 
# Config parametr batch update.
# default action is change.
#
# ---------------------------------------------

awk 'BEGIN{
	open_comment=0
	open_element=0
}
/<\?.*\?>/ {
	print $0
	next
}
/^[[:blank:]]*$/ {
	print $0
	next
}
/^[[:blank:]]*<!--/{
	open_comment=1
	print $0
	next
}
/^[[:blank:]]*-->/{
	open_comment=0
	print $0
	next
}
{
	if ($0 ~ /^[[:blank:]]*<\S*[[:blank:]]*/) {
		open_element=1
		print "open_element:::" $0
	}

	

	if ($0 ~ /^[[:blank:]]*<\/\S*>[[:blank:]]*/) {
		open_element=0
		print "close_element:::" $0
	}


	if (open_comment == 1) {
		if ($0 ~ /.*-->[[:blank:]]*/) {
			open_comment=0
		}
		print $0
		next
	}

	


}' server.xml